<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组的方法</title>
    <script>
        var arr = ["孙悟空","猪八戒","沙和尚"];

        //push()方法
        var result=arr.push("唐僧","蜘蛛精");
        console.log(arr);
        //返回新的长度
        console.log("result="+result);

        //pop()方法
        result=arr.pop();
        console.log(arr);
        console.log("result="+result);

        //unshift()方法
        result=arr.unshift("牛魔王","玉兔精");
        console.log(arr);
        console.log("result="+result);

        //shift()方法
        result=arr.shift();
        console.log(arr);
        console.log("result="+result);








    </script>
</head>
<body>
    
</body>
</html>